
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'homePageController.dart';
import 'mainPageView.dart';
import '../controller/constant.dart';
import 'package:remixicon/remixicon.dart';

class homePageView extends GetView<homePageController>{
  const homePageView({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context){
    
    //Get.put(homePageController());
    //OrientationBuilder 根据屏幕横向还是纵向，显示不同的列数
    return OrientationBuilder(
      builder: (context,orientation){
          //return mainPageView();
          return Scaffold(
            //appBar: AppBar(title:Text("fun2live"),),
            body:Row(
              children: [
                Expanded(
                  child:Obx(
                    () => Container(
                      decoration: BoxDecoration(
                        border: Border(
                          left: orientation == Orientation.landscape?
                              BorderSide(
                                color: Colors.grey.withOpacity(.2),
                                width: 1,
                              )
                              : BorderSide.none,
                              ),
                      ),
                      child: IndexedStack(
                        index: controller.index.value,
                        children: controller.pages,
                      ),
                      //  child: mainPageView() 
                    )
                  ) ,
                ),
                
              ],
            ),
              bottomNavigationBar:Visibility(
                visible: orientation == Orientation.portrait,
                child: Obx(
                  () => NavigationBar(
                    selectedIndex: controller.index.value,
                    onDestinationSelected:controller.setIndex,
                    height: 56,
                    labelBehavior: NavigationDestinationLabelBehavior.alwaysHide,
                    /*destinations: 
                    Constant.allHomePages
                      .map((key, value) => MapEntry(
                                    key, NavigationDestination(
                                            icon: Icon(value.iconData), 
                                            label: value.title))
                                            
                      ).values.toList(),*/
                    destinations: controller.items
                    .map(
                        (item) => NavigationDestination(
                          icon: Icon(item.iconData),
                          label: item.title,
                      ),
                    )
                    .toList(),
                  )
                ),
              ),
          );
      },
    );

  }
}